package com;

import com.mysql.jdbc.Driver;

import java.sql.*;

public class Hello {
    private static final String URL = "jdbc:mysql://192.168.1.29:3306/wechat?user=admin&password=Zhang@123456";
    private static final String USER = "admin";
    private static final String PASSWORD = "admin";

    public static void main(String[] arg) throws ClassNotFoundException, SQLException {
        //1. 加载驱动程序
        //反射，通过一个类型反向的将这个类加载的环境中
        Class.forName("com.mysql.cj.jdbc.Driver");
        //2. 获得数据库连接
        Connection conn = DriverManager.getConnection(URL);

        //3. 通过数据库连接操作数据，实现增删改查
        Statement stmt = conn.createStatement();
        ResultSet rs = stmt.executeQuery("select * from users");
        while (rs.next()) {
            System.out.println(rs.getString("uname"));
        }

    }
}
